package com.itheima.springboottlias.service.impl;


import Pojo.JobCountItem;
import com.itheima.springboottlias.mapper.EmpMapper;
import com.itheima.springboottlias.mapper.StudentMapper;
import com.itheima.springboottlias.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;

    //  查询员工职位数量
    @Override
    public Map empJobCount() {
        Map map = new HashMap<>();
        List<JobCountItem> jobCountItemList = empMapper.empJobCount();
        map.put("jobList", jobCountItemList.stream().map(item -> item.getName()).collect(Collectors.toList()));
        map.put("dataList", jobCountItemList.stream().map(item -> item.getValue()).collect(Collectors.toList()));


        return map;
    }
    // 查询员工性别数量
    @Override
    public List<Map> empGenderCount() {
        return empMapper.empGenderCount();
    }
    // 查询学生学历数量
    @Override
    public List<JobCountItem> stuDegreeCount() {


        return studentMapper.stuDEgreeCount();
    }

    @Override
    public Map stuClassCount() {
        List<Map> stuClassCount = studentMapper.stuClassCount();
        Map map=new HashMap<>();
        map.put("clazzList",stuClassCount.stream().map(item->item.get("name")).collect(Collectors.toList()));
        map.put("dataList",stuClassCount.stream().map(item->item.get("value")).collect(Collectors.toList()));
        return map;
    }

}
